import type { CodeType, LoginType2, UserData, UserType } from "@/type/user"
import { request } from "@/utils/http"

interface LoginType {
  mobile: string
  password: string
}



/**
 * @param obj 登录需要 手机号（string）+密码（string）
 */
export const loginByPassAPI = (obj: LoginType) =>
  request.post<null, UserType>("/login/password", obj)


export const getCodeAPI = (mobile:string ,type: CodeType)=> {
  return request.get<null, {code:string}>('/code', {
    params: {
      mobile: mobile,
      type:type
    }
  })
}

/**
 * 通过Code码 用于登录跳转
 */
export const loginByCodeAPI = (obj:LoginType2) => {
  return request.post<null, UserType>('/login',obj)
}

export const userInfoApi = () => {
  return request.get<null, UserData>('/patient/myUser')
}